<?php
namespace app\shell;

use app\service\Factory4GService;
use share\console\CLIRunner;
use share\service\RequestFMService;

class CRequestTest extends CLIRunner{

    public function mutil_test_action(){
        $url = "http://127.0.0.1/wait.php";
        $data0 = "t=1";
        $data1 = "t=2";
        $data2 =  "t=2";
        $data3 =  "t=3";
        $data4 =  "t=7";
        $data5 =  "t=8";
        $data5 =  "t=9";
        $data6 =  "t=15";
        $data7 =  "";
        $curlList = [];
        $callback = function($data){
            var_dump($data);
            if(isset($data['content'])){
                if(strpos($data['content'],'wait 6') !== false){
                    return ['data' => 'ok'];
                }
            }
            return false;
        };
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data0),
            'userData' => $data0,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data1),
            'userData' => $data1,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data2),
            'userData' => $data2,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data3),
            'userData' => $data3,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data4),
            'userData' => $data4,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data5),
            'userData' => $data5,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data6),
            'userData' => $data6,
        ];
        $curlList[] = [
            'handle' => Factory4GService::getSimpleCurlHandle($url,$data7),
            'userData' => $data7,
        ];
        $res = RequestFMService::mutilRequest($curlList,$callback);
        return $res;

    }
}